package com.zhiyi.xppay.utils;

import android.content.Context;
import android.content.Intent;

import com.zhiyi.xppay.consts.AppConstsNxys;
import com.zhiyi.xppay.hook.HookNxys;

/**
 * Created by pc_mg on 2019/3/6.
 */

public class ToolsNxys {
    public static boolean ishookeed;// hook到
    public static boolean isactivitystart;// activity开启

    public static void sendCreateQRCode(Context context, String money, String mark, String type){
        //
        Intent intent = new Intent();
        intent.setAction(AppConstsNxys.ACTION_CREATEQRCODE);
        intent.putExtra("money", ""+money);
        intent.putExtra("mark",mark);
        intent.putExtra("type", type);
        context.sendBroadcast(intent);
        //
    }

    public static void CreateQRCode(String money, String mark, String type) {
        HookNxys.createqr(money,mark,type);
    }

    public static void sendmsg(Context context, String msg) {
        Intent broadCastIntent = new Intent();
        broadCastIntent.putExtra("msg", msg);
        broadCastIntent.setAction(AppConstsNxys.ACTION_MSGRECEIVED);
        context.sendBroadcast(broadCastIntent);
    }

    public static void sendqrcod(Context context, String orderTime, String orderid, String qrlink, String username, String paytype, String money, String mark) {
        Intent broadCastIntent = new Intent();
        broadCastIntent.setAction(AppConstsNxys.ACTION_SENDQRCODE);
        broadCastIntent.putExtra("orderTime", orderTime);
        broadCastIntent.putExtra("orderid", orderid);
        broadCastIntent.putExtra("qrlink", qrlink);
        broadCastIntent.putExtra("username", username);
        broadCastIntent.putExtra("paytype", paytype);
        broadCastIntent.putExtra("money",money);
        broadCastIntent.putExtra("mark",mark);
        context.sendBroadcast(broadCastIntent);
    }

    public static void sendtrade(Context context, String payTime, String orderId, String realAmount, String merName, String type) {
        Intent broadCastIntent = new Intent();
        broadCastIntent.setAction(AppConstsNxys.ACTION_SENDTRADE);
        broadCastIntent.putExtra("payTime", payTime);
        broadCastIntent.putExtra("orderId", orderId);
        broadCastIntent.putExtra("realAmount", realAmount);
        broadCastIntent.putExtra("merName", merName);
        broadCastIntent.putExtra("type", type);
        context.sendBroadcast(broadCastIntent);
    }

    public static void sendActivitystart(Context context) {
        Intent intent = new Intent();
        intent.setAction(AppConstsNxys.ACTION_ACTIVITYSTART);
        context.sendBroadcast(intent);
    }

    public static void tradequery(Context context) {
        if (isactivitystart && ishookeed) {
            ToolsNxys.sendmsg(context,"农信易扫开启账单轮询");
            Intent broadCastIntent = new Intent();
            broadCastIntent.setAction(AppConstsNxys.ACTION_STARTTRADEQUERY);
            context.sendBroadcast(broadCastIntent);
        }
    }
}
